Function Reference

Hex

Returns a string representation of an integer or of a binaryString converted to hexadecimal.

Hex ( expression [, length] )

 

Parameters

number The expression to convert.
length [optional] Number of characters to be returned (up to 8) for integer.
Characters are truncated from the left-hand side if length is too small.
On binaryString the whole string is converted.

 

Return Value

Success: Returns a string of length characters, zero-padded if necessary for integer.
Returns the binaryString converted.
Special: Returns "" (blank string) if length is less than 1.
Failure: Returns "" (blank string) and sets @error to 1 if length is greater than 8.

 

Remarks

The function only works with numbers that fit in a 32 bit signed integer (-2147483648 to 2147483647)

The function will also set @error to 1 if not enough digits were requested - the returned string will return the least significant digits in this case.

 

Related

Dec

 

Example


$result = Hex(1033, 4)  ;returns "0409"